package com.example.demo.controller;


import com.example.demo.entity.Classroom;
import com.example.demo.service.ClassroomServices;
import com.example.demo.dto.ResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/classroom")
public class ClassroomController {

    @Autowired
    ClassroomServices classroomServices;

    @RequestMapping("getAll.action")
    public ResultDTO getAll() {
        ResultDTO resultDTO = new ResultDTO();

        resultDTO.setResult(true);
        resultDTO.setMessage("班级查询成功");
        ArrayList<Classroom> classrooms = classroomServices.getAll();
        resultDTO.setData(classrooms);
        return resultDTO;
    }

    @RequestMapping("getAllByStus.action")
    public ResultDTO getAllByStus() {
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setResult(true);
        resultDTO.setMessage("班级查询并且知道所有的学生成功");
        ArrayList<Classroom> classrooms = classroomServices.getAllByStus();
        resultDTO.setData(classrooms);
        return resultDTO;
    }
}
